

********************************************************************************
*Purpose: Calculate pathway scores underlying Figure 4 and 5 of the manuscript**
*Stata Version: 17
*By Marc van de Wardt (m.p.vande.wardt@vu.nl)
********************************************************************************

**Install additional packages needed

ssc install blindschemes, replace
net install blindschemes_fix, replace from("http://digital.cgdev.org/doc/stata/MO/Misc")

**Set working directory

cd "C:\Users\LT-054912\surfdrive\Diffusion\dataverse files\"

**Open log files\

log using "Stata do-file to create Figure A3 and A4.smcl", replace

******
**H1**
******

use "dataset for analysis.dta", clear

reg ln_totentry2_ipol wy_lag_ln_totentry2_ipol wx_lag_votperforentrants2_ipol c.wx_lag_density_ipol##c.wx_lag_density_ipol c.wx_lag_votperfor_ipol##c.wx_lag_votperfor_ipol lag_ln_totentry2_ipol lag_VoterTurnout_ipol  avemag_des_new_ipol  lag_RegV_ipol lnpopnew_ipol gdpgrowth_oecd_ipol diff_unemp_ipol corporatism_z_sm537_ipol enep_new_ipol  sig_dum_ipol deposit_dum_ipol funding_dum_ipol i.unit_fe i.elec_year
predict full, resid
gen full2=abs(full-0)
 
reg ln_totentry2_ipol wx_lag_votperforentrants2_ipol c.wx_lag_density_ipol##c.wx_lag_density_ipol c.wx_lag_votperfor_ipol##c.wx_lag_votperfor_ipol lag_ln_totentry2_ipol lag_VoterTurnout_ipol  avemag_des_new_ipol  lag_RegV_ipol lnpopnew_ipol gdpgrowth_oecd_ipol diff_unemp_ipol corporatism_z_sm537_ipol enep_new_ipol  sig_dum_ipol deposit_dum_ipol funding_dum_ipol i.unit_fe i.elec_year
predict reduc, resid
gen reduc2=abs(reduc-0)

gen pathwayabs=abs(reduc-full)

gen closer=0
replace closer=1 if full2<reduc2

gen pathways1=pathwayabs if closer==1
replace pathways1=(pathwayabs*-1) if closer==0

encode family_dynamic1, gen(fam)

preserve

keep family_dynamic1 country_ipol elec_year pathways1 totentry2_ipol

save "pathway scores h1.dta", replace

restore

**Only select core families that at least produced 10 unique parties

keep if family_dynamic1=="Anarchist" |  family_dynamic1=="Animalists" |  family_dynamic1=="Anti-Europe" |  family_dynamic1=="Blanco" |  family_dynamic1=="Christian catch-all parties" |  family_dynamic1=="Christian conservatism" |  family_dynamic1=="Christian socialism" |  family_dynamic1=="Communists" |  family_dynamic1=="Conservatives" |  family_dynamic1=="Corruption and transparency" |  family_dynamic1=="Democratic socialists" |  family_dynamic1=="Extreme right" |  family_dynamic1=="Feminists" |  family_dynamic1=="Greens" |  family_dynamic1=="Humanism" |  family_dynamic1=="Immigrant counter mobilization" |  family_dynamic1=="Liberals" |  family_dynamic1=="Marginalized people" |  family_dynamic1=="Neoliberal Populists" |  family_dynamic1=="Non-populist radical right" |  family_dynamic1=="Other New Left" |  family_dynamic1=="Pensioners" |  family_dynamic1=="Pirate" |  family_dynamic1=="Public participation" |  family_dynamic1=="Radical Right Populists" |  family_dynamic1=="Regionalist" |  family_dynamic1=="Republic" |  family_dynamic1=="Rural" |  family_dynamic1=="Satirical" |  family_dynamic1=="Small business" |  family_dynamic1=="Social democrat" |  family_dynamic1=="Social liberals" |  family_dynamic1=="Spiritual" |  family_dynamic1=="Taxation" |  family_dynamic1=="Unionism" |  family_dynamic1=="Unite transborder language communities" |  family_dynamic1=="Working class" |  family_dynamic1=="Young people"

graph box pathways1 if totentry2_ipol!=0, over(fam, label(angle(vertical) labsize(small))) ytitle(Pathway score) scheme(plottig) title(Pathway scores (H1)) name(b, replace)
graph export "FigureA3.tif", replace

******
**H4**
******

use "dataset for analysis.dta", clear

reg ln_totentry2_ipol wy_lag_ln_totentry2_ipol wx_lag_votperforentrants2_ipol c.wx_lag_density_ipol##c.wx_lag_density_ipol c.wx_lag_votperfor_ipol##c.wx_lag_votperfor_ipol lag_ln_totentry2_ipol lag_VoterTurnout_ipol  avemag_des_new_ipol  lag_RegV_ipol lnpopnew_ipol gdpgrowth_oecd_ipol diff_unemp_ipol corporatism_z_sm537_ipol enep_new_ipol  sig_dum_ipol deposit_dum_ipol funding_dum_ipol i.unit_fe i.elec_year
predict full, resid
gen full2=abs(full-0)

reg ln_totentry2_ipol wy_lag_ln_totentry2_ipol wx_lag_votperforentrants2_ipol c.wx_lag_density_ipol##c.wx_lag_density_ipol lag_ln_totentry2_ipol lag_VoterTurnout_ipol  avemag_des_new_ipol  lag_RegV_ipol lnpopnew_ipol gdpgrowth_oecd_ipol diff_unemp_ipol corporatism_z_sm537_ipol enep_new_ipol  sig_dum_ipol deposit_dum_ipol funding_dum_ipol i.unit_fe i.elec_year
predict reduc, resid
gen reduc2=abs(reduc-0)

gen pathwayabs=abs(reduc-full)

gen closer=0
replace closer=1 if full2<reduc2

gen pathways1=pathwayabs if closer==1
replace pathways1=(pathwayabs*-1) if closer==0

encode family_dynamic1, gen(fam)

preserve

keep family_dynamic1 country_ipol elec_year pathways1 totentry2_ipol

save "pathway scores h4.dta", replace

restore

**Only select core families that at least produced 10 unique parties

keep if family_dynamic1=="Anarchist" |  family_dynamic1=="Animalists" |  family_dynamic1=="Anti-Europe" |  family_dynamic1=="Blanco" |  family_dynamic1=="Christian catch-all parties" |  family_dynamic1=="Christian conservatism" |  family_dynamic1=="Christian socialism" |  family_dynamic1=="Communists" |  family_dynamic1=="Conservatives" |  family_dynamic1=="Corruption and transparency" |  family_dynamic1=="Democratic socialists" |  family_dynamic1=="Extreme right" |  family_dynamic1=="Feminists" |  family_dynamic1=="Greens" |  family_dynamic1=="Humanism" |  family_dynamic1=="Immigrant counter mobilization" |  family_dynamic1=="Liberals" |  family_dynamic1=="Marginalized people" |  family_dynamic1=="Neoliberal Populists" |  family_dynamic1=="Non-populist radical right" |  family_dynamic1=="Other New Left" |  family_dynamic1=="Pensioners" |  family_dynamic1=="Pirate" |  family_dynamic1=="Public participation" |  family_dynamic1=="Radical Right Populists" |  family_dynamic1=="Regionalist" |  family_dynamic1=="Republic" |  family_dynamic1=="Rural" |  family_dynamic1=="Satirical" |  family_dynamic1=="Small business" |  family_dynamic1=="Social democrat" |  family_dynamic1=="Social liberals" |  family_dynamic1=="Spiritual" |  family_dynamic1=="Taxation" |  family_dynamic1=="Unionism" |  family_dynamic1=="Unite transborder language communities" |  family_dynamic1=="Working class" |  family_dynamic1=="Young people"

graph box pathways1 if totentry2_ipol!=0, over(fam, label(angle(vertical) labsize(small))) ytitle(Pathway score) scheme(plottig) title(Pathway scores (H4)) name(b, replace)
graph export "FigureA4.tif", replace

log close


